package com.opener.web.auth.service;


import com.opener.web.auth.model.UserAuthToken;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *
 * @author baboy
 * @date 08/12/2016
 */
public interface UserAuthService {

    int addAuthToken(UserAuthToken token);
    boolean updateAuthToken(UserAuthToken token);
    List<UserAuthToken> getAuthTokens(int uid, String domain, String platform);

    UserAuthToken getLastAuthTokenByOs(Integer uid, String os);
    UserAuthToken getAuthTokenByUkey(String ukey);


    UserAuthToken createUserAuthToken(UserAuthToken token);
    UserAuthToken createUserAuthToken(Long uid, String domain, HttpServletRequest request);
    UserAuthToken createUserAuthToken(Long uid, HttpServletRequest request);

    /**
     * 校验ukey
     * @param ukey
     * @param deviceId
     * @return
     */
    UserAuthToken getCheckedAuthToken(String ukey, String domain, String platform, String deviceId);
    UserAuthToken getCheckedAuthToken(String ukey, String domain, HttpServletRequest request) ;
    UserAuthToken getCheckedAuthToken(HttpServletRequest request);

    void loginWithCookie(UserAuthToken token, HttpServletResponse response);
    void logoutWithCookie(UserAuthToken token, HttpServletResponse response);

}
